﻿/*******************************************************************************
Copyright (c) 2011-2013, PKStudio
Copyright (c) 2011,      Zynga Inc.
Copyright (c) 2008-2010, Ricardo Quesada

http://pkstudio.org

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*******************************************************************************/
using System;
using System.Diagnostics;
using System.Drawing;

namespace PKEngine
{
	/// <summary>
	/// Delegate for Event.
	/// </summary>
	public delegate void EventDelegate(object sender);

	/// <summary>
	/// PKMenuItem base class.
	/// </summary>
	public class PKMenuItem : PKNode
	{
		#region Private Fields
		private bool isEnabled;
		#endregion

		#region Public Properties
		/// <summary>
		/// TargetDelegate property of PKMenuItem.
		/// </summary>
		public EventDelegate TargetDelegate { get; set; }

		/// <summary>
		/// Whether or not the item is selected.
		/// </summary>
		public bool IsSelected { get; private set; }

		/// <summary>
		/// Whether or not the item is enabled.
		/// </summary>
		public virtual bool IsEnabled
		{
			get
			{
				return this.isEnabled;
			}
			set
			{
				this.isEnabled = value;
			}
		}
		#endregion

		#region Initialization
		public PKMenuItem()
			: this(null)
		{
		}

		public PKMenuItem(EventDelegate targetDelegate)
			: base()
		{
			this.TargetDelegate = targetDelegate;
			this.isEnabled = true;
			this.IsSelected = false;
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Select the menu item.
		/// </summary>
		public virtual void Select()
		{
			IsSelected = true;
		}

		/// <summary>
		/// Unselect the menu item.
		/// </summary>
		public virtual void Unselect()
		{
			IsSelected = false;
		}

		/// <summary>
		/// Activate the menu item.
		/// </summary>
		public virtual void Activate()
		{
			if (IsEnabled && TargetDelegate != null)
			{
				TargetDelegate(this);
			}
		}
		#endregion
	}

	/// <summary>
	/// PKMenuItemLabel class.
	/// </summary>
	public class PKMenuItemLabel : PKMenuItem, IPKRgba
	{
		#region Private Fields
		private PKSpriteDisplayMode originalMode;
		private ushort originalColor;
		private ushort selectedColor;
		private ushort disabledColor;
		private bool hasSelectedColor;
		private bool hasDisabledColor;
		#endregion

		#region Public Properties
		/// <summary>
		/// Sub Label of PKMenuItemLabel.
		/// </summary>
		public IPKLabel Label { get; private set; }

		public int Opacity
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.Opacity;
				}
				return 256;
			}
			set
			{
				if (this.Label != null)
				{
					this.Label.Opacity = value;
				}
			}
		}

		public ushort Color
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.Color;
				}
				return PKAlpha.SharedAlpha.ColorWhite;
			}
			set
			{
				if (this.Label != null)
				{
					this.Label.Color = value;
				}
			}
		}

		public int ColorOpacity
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.ColorOpacity;
				}
				return 256;
			}
			set
			{
				if (this.Label != null)
				{
					this.Label.ColorOpacity = value;
				}
			}
		}

		public int DisplayedOpacity
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.DisplayedOpacity;
				}
				return 256;
			}
		}

		public ushort DisplayedColor
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.DisplayedColor;
				}
				return PKAlpha.SharedAlpha.ColorWhite;
			}
		}

		public int DisplayedColorOpacity
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.DisplayedColorOpacity;
				}
				return 256;
			}
		}

		/// <summary>
		/// Whether or not opacity should be propagated to its children.
		/// </summary>
		public bool CascadeOpacityEnabled { get; set; }

		/// <summary>
		/// Whether or not color should be propagated to its children.
		/// </summary>
		public bool CascadeColorEnabled { get; set; }

		public string Text
		{
			get
			{
				if (this.Label != null)
				{
					return this.Label.Text;
				}
				return null;
			}
			set
			{
				if (this.Label != null)
				{
					this.Label.Text = value;
					this.ContentSize = (this.Label as PKNode).ContentSize;
				}
			}
		}

		public ushort SelectedColor
		{
			get
			{
				if (this.hasSelectedColor)
				{
					return this.selectedColor;
				}
				return PKAlpha.SharedAlpha.ColorKey;
			}
			set
			{
				if (value == PKAlpha.SharedAlpha.ColorKey)
				{
					this.hasSelectedColor = false;
				}
				else
				{
					this.hasSelectedColor = true;
					this.selectedColor = value;
				}
			}
		}

		public ushort DisabledColor
		{
			get
			{
				if (this.hasDisabledColor)
				{
					return this.disabledColor;
				}
				return PKAlpha.SharedAlpha.ColorKey;
			}
			set
			{
				if (value == PKAlpha.SharedAlpha.ColorKey)
				{
					this.hasDisabledColor = false;
					if (!this.IsEnabled && this.Label != null)
					{
						this.Label.DisplayMode = originalMode;
						this.Label.Color = originalColor;
					}
				}
				else
				{
					this.hasDisabledColor = true;
					this.disabledColor = value;
					if (!this.IsEnabled && this.Label != null)
					{
						this.Label.DisplayMode = PKSpriteDisplayMode.Color;
						this.Label.Color = disabledColor;
					}
				}
			}
		}

		public override bool IsEnabled
		{
			get
			{
				return base.IsEnabled;
			}
			set
			{
				if (this.IsEnabled != value)
				{
					if (value)
					{
						if (this.Label != null)
						{
							this.Label.DisplayMode = originalMode;
							this.Label.Color = originalColor;
						}
					}
					else
					{
						if (this.Label != null)
						{
							originalMode = this.Label.DisplayMode;
							originalColor = this.Label.Color;
							if (hasDisabledColor)
							{
								this.Label.DisplayMode = PKSpriteDisplayMode.Color;
								this.Label.Color = disabledColor;
							}
						}
					}
					base.IsEnabled = value;
				}
			}
		}
		#endregion

		#region Initialization
		public static PKMenuItemLabel ItemMake(IPKLabel label)
		{
			return new PKMenuItemLabel().Init(label);
		}

		public static PKMenuItemLabel ItemMake(IPKLabel label, EventDelegate targetDelegate)
		{
			return new PKMenuItemLabel().Init(label, targetDelegate);
		}

		public virtual PKMenuItemLabel Init(IPKLabel label)
		{
			return this.Init(label, null);
		}

		public virtual PKMenuItemLabel Init(IPKLabel label, EventDelegate targetDelegate)
		{
			Debug.Assert(label != null, "PKMenuItemLabel: Argument cannot be null.");

			label.ColorOpacity = 128;
			this.Label = label;
			this.TargetDelegate = targetDelegate;
			PKNode tempNode = this.Label as PKNode;
			this.AddChild(tempNode);
			this.ContentSize = tempNode.ContentSize;
			this.disabledColor = PKAlpha.SharedAlpha.ColorFromRgb(128, 128, 128);
			this.hasDisabledColor = true;
			this.selectedColor = PKAlpha.SharedAlpha.ColorFromRgb(0, 255, 255);
			this.hasSelectedColor = true;

			return this;
		}
		#endregion

		#region IPKRgba Methods
		public void UpdateDisplayedOpacity(int parentOpacity)
		{
		}

		public void UpdateDisplayedColor(ushort parentColor, int parentColorOpacity)
		{
		}
		#endregion

		#region Public Methods
		public override void Activate()
		{
			if (IsEnabled)
			{
				if (this.Label != null)
				{
					this.Label.DisplayMode = originalMode;
					this.Label.Color = originalColor;
				}

				base.Activate();
			}
		}

		public override void Select()
		{
			if (IsEnabled)
			{
				if (this.Label != null)
				{
					if (!IsSelected)
					{
						originalMode = this.Label.DisplayMode;
						originalColor = this.Label.Color;
					}
					if (hasSelectedColor)
					{
						this.Label.DisplayMode = PKSpriteDisplayMode.Color;
						this.Label.Color = selectedColor;
					}
				}
				base.Select();
			}
		}

		public override void Unselect()
		{
			if (IsEnabled)
			{
				base.Unselect();
				if (this.Label != null)
				{
					this.Label.DisplayMode = originalMode;
					this.Label.Color = originalColor;
				}
			}
		}
		#endregion
	}

	/// <summary>
	/// PKMenuItemSprite class.
	/// </summary>
	public class PKMenuItemSprite : PKMenuItem, IPKRgba
	{
		#region Privat Fields
		private PKSpriteFrame disabledFrame;
		private PKSpriteFrame selectedFrame;
		private PKSpriteDisplayMode originalMode;
		private ushort originalColor;
		private PKSpriteFrame originalFrame;
		#endregion

		#region Publib Properties
		/// <summary>
		/// Sub Sprite of PKMenuItemSprite.
		/// </summary>
		public PKSprite Sprite { get; private set; }

		public int Opacity
		{
			get
			{
				if (this.Sprite != null)
				{
					return this.Sprite.Opacity;
				}
				return 256;
			}
			set
			{
				if (this.Sprite != null)
				{
					this.Sprite.Opacity = value;
				}
			}
		}

		public ushort Color
		{
			get
			{
				if (this.Sprite != null)
				{
					return this.Sprite.Color;
				}
				return PKAlpha.SharedAlpha.ColorWhite;
			}
			set
			{
				if (this.Sprite != null)
				{
					this.Sprite.Color = value;
				}
			}
		}

		public int ColorOpacity
		{
			get
			{
				if (this.Sprite != null)
				{
					return this.Sprite.ColorOpacity;
				}
				return 256;
			}
			set
			{
				if (this.Sprite != null)
				{
					this.Sprite.ColorOpacity = value;
				}
			}
		}

		public int DisplayedOpacity { get; set; }

		public ushort DisplayedColor { get; set; }

		public int DisplayedColorOpacity { get; set; }

		/// <summary>
		/// Whether or not opacity should be propagated to its children.
		/// </summary>
		public bool CascadeOpacityEnabled { get; set; }

		/// <summary>
		/// Whether or not color should be propagated to its children.
		/// </summary>
		public bool CascadeColorEnabled { get; set; }

		public override bool IsEnabled
		{
			get
			{
				return base.IsEnabled;
			}
			set
			{
				if (this.IsEnabled != value)
				{
					if (value)
					{
						if (this.Sprite != null)
						{
							this.Sprite.DisplayMode = originalMode;
							this.Sprite.Color = originalColor;
							this.Sprite.SetDisplayFrame(originalFrame);
						}
					}
					else
					{
						if (this.Sprite != null)
						{
							originalMode = this.Sprite.DisplayMode;
							originalColor = this.Sprite.Color;
							originalFrame = this.Sprite.GetDisplayFrame();
							if (this.DisabledFrame == null)
							{
								this.Sprite.DisplayMode = PKSpriteDisplayMode.Tint;
								this.Sprite.Color = PKAlpha.SharedAlpha.ColorBlack;
							}
							else
							{
								this.Sprite.SetDisplayFrame(disabledFrame);
							}
						}
					}
					base.IsEnabled = value;
				}
			}
		}

		/// <summary>
		/// The frame to show when menu item is disabled.
		/// </summary>
		public PKSpriteFrame DisabledFrame
		{
			get
			{
				return this.disabledFrame;
			}
			set
			{
				this.disabledFrame = value;
				if (!this.IsEnabled && this.Sprite != null)
				{
					if (disabledFrame == null)
					{
						this.Sprite.DisplayMode = PKSpriteDisplayMode.Tint;
						this.Sprite.Color = PKAlpha.SharedAlpha.ColorBlack;
						this.Sprite.SetDisplayFrame(originalFrame);
					}
					else
					{
						this.Sprite.DisplayMode = originalMode;
						this.Sprite.Color = originalColor;
						this.Sprite.SetDisplayFrame(disabledFrame);
					}
				}
			}
		}

		/// <summary>
		/// The frame to show when menu item is clicked.
		/// </summary>
		public PKSpriteFrame SelectedFrame
		{
			get
			{
				return this.selectedFrame;
			}
			set
			{
				this.selectedFrame = value;
			}
		}
		#endregion

		#region Initialization
		public static PKMenuItemSprite ItemMake(PKSprite sprite)
		{
			return new PKMenuItemSprite().Init(sprite);
		}

		public static PKMenuItemSprite ItemMake(PKSprite sprite, EventDelegate targetDelegate)
		{
			return new PKMenuItemSprite().Init(sprite, targetDelegate);
		}

		public static PKMenuItemSprite ItemMake(PKSurface surface)
		{
			return new PKMenuItemSprite().Init(surface);
		}

		public static PKMenuItemSprite ItemMake(PKSurface surface, Rectangle rect)
		{
			return new PKMenuItemSprite().Init(surface, rect);
		}

		public static PKMenuItemSprite ItemMake(string fileName)
		{
			return new PKMenuItemSprite().Init(fileName);
		}

		public static PKMenuItemSprite ItemMake(string fileName, Rectangle rect)
		{
			return new PKMenuItemSprite().Init(fileName, rect);
		}

		public virtual PKMenuItemSprite Init(PKSprite sprite)
		{
			return this.Init(sprite, null);
		}

		public virtual PKMenuItemSprite Init(PKSprite sprite, EventDelegate targetDelegate)
		{
			Debug.Assert(sprite != null, "PKMenuItemSprite: Argument cannot be null.");

			sprite.ColorOpacity = 128;
			this.Sprite = sprite;
			this.TargetDelegate = targetDelegate;
			this.AddChild(this.Sprite);
			this.ContentSize = this.Sprite.ContentSize;
			this.disabledFrame = null;
			this.selectedFrame = null;

			return this;
		}

		public virtual PKMenuItemSprite Init(PKSurface surface)
		{
			return this.Init(new PKSprite(surface), null);
		}

		public virtual PKMenuItemSprite Init(PKSurface surface, Rectangle rect)
		{
			return this.Init(new PKSprite(surface, rect), null);
		}

		public virtual PKMenuItemSprite Init(string fileName)
		{
			return this.Init(new PKSprite(fileName), null);
		}

		public virtual PKMenuItemSprite Init(string fileName, Rectangle rect)
		{
			return this.Init(new PKSprite(fileName, rect), null);
		}
		#endregion

		#region IPKRgba Methods
		public void UpdateDisplayedOpacity(int parentOpacity)
		{
		}

		public void UpdateDisplayedColor(ushort parentColor, int parentColorOpacity)
		{
		}
		#endregion

		#region Public Methods
		public override void Activate()
		{
			if (IsEnabled)
			{
				if (this.Sprite != null)
				{
					this.Sprite.DisplayMode = originalMode;
					this.Sprite.Color = originalColor;
					this.Sprite.SetDisplayFrame(originalFrame);
				}

				base.Activate();
			}
		}

		public override void Select()
		{
			if (IsEnabled)
			{
				if (this.Sprite != null)
				{
					if (!IsSelected)
					{
						originalMode = this.Sprite.DisplayMode;
						originalColor = this.Sprite.Color;
						originalFrame = this.Sprite.GetDisplayFrame();
					}
					if (SelectedFrame == null)
					{
						this.Sprite.DisplayMode = PKSpriteDisplayMode.Tint;
						this.Sprite.Color = PKAlpha.SharedAlpha.ColorWhite;
					}
					else
					{
						this.Sprite.SetDisplayFrame(SelectedFrame);
					}
				}
				base.Select();
			}
		}

		public override void Unselect()
		{
			if (IsEnabled)
			{
				base.Unselect();
				if (this.Sprite != null)
				{
					this.Sprite.DisplayMode = originalMode;
					this.Sprite.Color = originalColor;
					this.Sprite.SetDisplayFrame(originalFrame);
				}
			}
		}
		#endregion
	}

	/// <summary>
	/// PKMenuItemSpriteSet class.
	/// </summary>
	public class PKMenuItemSpriteSet : PKMenuItem, IPKRgba
	{
		#region Private Fields
		private PKSprite disabledSprite;
		private PKSprite selectedSprite;
		#endregion

		#region Publib Properties
		public int Opacity
		{
			get
			{
				return this.NormalSprite.Opacity;
			}
			set
			{
				this.NormalSprite.Opacity = value;
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.Opacity = value;
				}
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.Opacity = value;
				}
			}
		}

		public int ColorOpacity
		{
			get
			{
				return this.NormalSprite.ColorOpacity;
			}
			set
			{
				this.NormalSprite.ColorOpacity = value;
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.ColorOpacity = value;
				}
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.ColorOpacity = value;
				}
			}
		}

		public ushort Color
		{
			get
			{
				return this.NormalSprite.Color;
			}
			set
			{
				this.NormalSprite.Color = value;
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.Color = value;
				}
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.Color = value;
				}
			}
		}

		public int DisplayedOpacity { get; set; }

		public ushort DisplayedColor { get; set; }

		public int DisplayedColorOpacity { get; set; }

		/// <summary>
		/// Whether or not opacity should be propagated to its children.
		/// </summary>
		public bool CascadeOpacityEnabled { get; set; }

		/// <summary>
		/// Whether or not color should be propagated to its children.
		/// </summary>
		public bool CascadeColorEnabled { get; set; }

		public override bool IsEnabled
		{
			get
			{
				return base.IsEnabled;
			}
			set
			{
				if (this.IsEnabled != value)
				{
					base.IsEnabled = value;
					this.UpdateVisibleHelper();
				}
			}
		}

		/// <summary>
		/// The Sprite to show when menu item is normal.
		/// </summary>
		public PKSprite NormalSprite { get; private set; }

		/// <summary>
		/// The Sprite to show when menu item is disabled.
		/// </summary>
		public PKSprite DisabledSprite
		{
			get
			{
				return this.disabledSprite;
			}
			set
			{
				if (value != this.disabledSprite)
				{
					this.RemoveChild(this.disabledSprite, true);
					this.AddChild(value);
					this.disabledSprite = value;
					this.UpdateVisibleHelper();
				}
			}
		}

		/// <summary>
		/// The Sprite to show when menu item is clicked.
		/// </summary>
		public PKSprite SelectedSprite
		{
			get
			{
				return this.selectedSprite;
			}
			set
			{
				if (value != this.selectedSprite)
				{
					this.RemoveChild(this.selectedSprite, true);
					this.AddChild(value);
					this.selectedSprite = value;
					this.UpdateVisibleHelper();
				}
			}
		}
		#endregion

		#region Initialization
		public static PKMenuItemSpriteSet ItemMake(PKSprite normalSprite, PKSprite disabledSprite, PKSprite selectedSprite)
		{
			return new PKMenuItemSpriteSet().Init(normalSprite, disabledSprite, selectedSprite);
		}

		public static PKMenuItemSpriteSet ItemMake(PKSprite normalSprite, PKSprite disabledSprite, PKSprite selectedSprite, EventDelegate targetDelegate)
		{
			return new PKMenuItemSpriteSet().Init(normalSprite, disabledSprite, selectedSprite, targetDelegate);
		}

		public static PKMenuItemSpriteSet ItemMake(string fileNormal)
		{
			return new PKMenuItemSpriteSet().Init(fileNormal);
		}

		public static PKMenuItemSpriteSet ItemMake(string fileNormal, string fileDisabled)
		{
			return new PKMenuItemSpriteSet().Init(fileNormal, fileDisabled);
		}

		public static PKMenuItemSpriteSet ItemMake(string fileNormal, string fileDisabled, string fileSelected)
		{
			return new PKMenuItemSpriteSet().Init(fileNormal, fileDisabled, fileSelected);
		}

		public virtual PKMenuItemSpriteSet Init(PKSprite normalSprite, PKSprite disabledSprite, PKSprite selectedSprite)
		{
			return this.Init(normalSprite, disabledSprite, selectedSprite, null);
		}

		public virtual PKMenuItemSpriteSet Init(PKSprite normalSprite, PKSprite disabledSprite, PKSprite selectedSprite, EventDelegate targetDelegate)
		{
			Debug.Assert(normalSprite != null, "PKMenuItemSpriteSet: Argument cannot be null.");

			this.NormalSprite = normalSprite;
			this.disabledSprite = disabledSprite;
			this.selectedSprite = selectedSprite;
			this.TargetDelegate = targetDelegate;
			this.ContentSize = this.NormalSprite.ContentSize;
			this.AddChild(this.NormalSprite);
			if (this.DisabledSprite != null)
			{
				this.AddChild(this.DisabledSprite);
				this.DisabledSprite.IsVisible = false;
			}
			if (this.SelectedSprite != null)
			{
				this.AddChild(this.SelectedSprite);
				this.SelectedSprite.IsVisible = false;
			}

			return this;
		}

		public virtual PKMenuItemSpriteSet Init(string fileNormal)
		{
			return this.Init(new PKSprite(fileNormal), null, null, null);
		}

		public virtual PKMenuItemSpriteSet Init(string fileNormal, string fileDisabled)
		{
			return this.Init(new PKSprite(fileNormal), new PKSprite(fileDisabled), null, null);
		}

		public virtual PKMenuItemSpriteSet Init(string fileNormal, string fileDisabled, string fileSelected)
		{
			return this.Init(new PKSprite(fileNormal), new PKSprite(fileDisabled), new PKSprite(fileSelected), null);
		}
		#endregion

		#region IPKRgba Methods
		public void UpdateDisplayedOpacity(int parentOpacity)
		{
		}

		public void UpdateDisplayedColor(ushort parentColor, int parentColorOpacity)
		{
		}
		#endregion

		#region Public Methods
		public override void Activate()
		{
			if (IsEnabled)
			{
				this.NormalSprite.IsVisible = true;
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.IsVisible = false;
				}
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.IsVisible = false;
				}

				base.Activate();
			}
		}

		public override void Select()
		{
			if (IsEnabled)
			{
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.IsVisible = false;
				}
				if (this.SelectedSprite != null)
				{
					this.NormalSprite.IsVisible = false;
					this.SelectedSprite.IsVisible = true;
				}
				else
				{
					this.NormalSprite.IsVisible = true;
				}

				base.Select();
			}
		}

		public override void Unselect()
		{
			if (IsEnabled)
			{
				base.Unselect();

				this.NormalSprite.IsVisible = true;
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.IsVisible = false;
				}
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.IsVisible = false;
				}
			}
		}
		#endregion

		#region Private Methods
		private void UpdateVisibleHelper()
		{
			if (IsEnabled)
			{
				if (this.DisabledSprite != null)
				{
					this.DisabledSprite.IsVisible = false;
				}
				if (IsSelected)
				{
					if (this.SelectedSprite != null)
					{
						this.NormalSprite.IsVisible = false;
						this.SelectedSprite.IsVisible = true;
					}
					else
					{
						this.NormalSprite.IsVisible = true;
					}
				}
				else
				{
					if (this.SelectedSprite != null)
					{
						this.SelectedSprite.IsVisible = false;
					}
					this.NormalSprite.IsVisible = true;
				}
			}
			else
			{
				if (this.SelectedSprite != null)
				{
					this.SelectedSprite.IsVisible = false;
				}
				if (this.DisabledSprite != null)
				{
					this.NormalSprite.IsVisible = false;
					this.DisabledSprite.IsVisible = true;
				}
				else
				{
					this.NormalSprite.IsVisible = true;
				}
			}
		}
		#endregion
	}
}
